package com.blb.marrysystem.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blb.marrysystem.dao.TbShoppingcartDao;
import com.blb.marrysystem.entity.TbShoppingcart;
import com.blb.marrysystem.service.TbShoppingcartService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (TbShoppingcart)表服务实现类
 *
 * @author makejava
 * @since 2023-01-11 09:22:32
 */
@Service
public class TbShoppingcartServiceImpl implements TbShoppingcartService {
    @Resource
    private TbShoppingcartDao tbShoppingcartDao;

    /**
     * 通过ID查询单条数据
     *
     * @param shoppingcartId 主键
     * @return 实例对象
     */
    @Override
    public TbShoppingcart queryById(String shoppingcartId) {
        return this.tbShoppingcartDao.queryById(shoppingcartId);
    }

    /**
     * 分页查询
     *


     * @return 查询结果
     */
    @Override
    public Page<TbShoppingcart> queryByPage() {
        return null;
    }

    /**
     * 新增数据
     *
     * @param tbShoppingcart 实例对象
     * @return 实例对象
     */
    @Override
    public TbShoppingcart insert(TbShoppingcart tbShoppingcart) {
        this.tbShoppingcartDao.insert(tbShoppingcart);
        return tbShoppingcart;
    }

    /**
     * 修改数据
     *
     * @param tbShoppingcart 实例对象
     * @return 实例对象
     */
    @Override
    public TbShoppingcart update(TbShoppingcart tbShoppingcart) {
        this.tbShoppingcartDao.update(tbShoppingcart);
        return this.queryById(tbShoppingcart.getShoppingcartId());
    }

    /**
     * 通过主键删除数据
     *
     * @param shoppingcartId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String shoppingcartId) {
        return this.tbShoppingcartDao.deleteById(shoppingcartId) > 0;
    }
}
